package com.hiv.context;

import com.hiv.common.Constants;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Locale;

/**
 * 系统请求信息
 */
public class SystemInfo implements Serializable {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 7882616678077068279L;

    /**
     * 请求路径 例如：/test/test1.json
     */
    private String reqPath;
    /**
     * 请求全路径，包含参数信息 例如：http://test.com/test/test1.json?xx=xx
     */
    private String reqFullPath;

    /**
     * 请求referer
     */
    private String referer;
    /**
     * userAgent
     */
    private String userAgent;
    /**
     * 用户ip地址
     */
    private String clientIp;

    private Locale locale;

    public String getReqPath() {
        return reqPath;
    }

    public void setReqPath(String reqPath) {
        this.reqPath = reqPath;
    }

    public String getReqFullPath() {
        return reqFullPath;
    }

    public void setReqFullPath(String reqFullPath) {
        this.reqFullPath = reqFullPath;
    }

    public String getReferer() {
        return referer;
    }

    public void setReferer(String referer) {
        this.referer = referer;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getClientIp() {
        if(StringUtils.isNotEmpty(clientIp)){
            return clientIp;
        }else {
            return "";
        }
    }

    public void setClientIp(String clientIp) {
        this.clientIp = clientIp;
    }

    public Locale getLocale() {
        if(locale == null){
            return Constants.DEFAULT_LOCAL;
        }
        return locale;
    }

    public void setLocale(Locale locale) {
        this.locale = locale;
    }
}